<!DOCTYPE html>
<html>
	<head>
		<#include "/templates/commons/head.html">
		<style type="text/css">
			.upload-file-btn-group {
				text-align: center;
			}
		</style>
		<script type="text/javascript">
			var fileData = null,//文件上传后返回文件信息
				isLoading = false;//文件是否正在上传
			function ready() {
			    update.render({
					url:'${ctx!}/UploadFileController/upload.do',
					data: {
					    fileSubDir : $("#folder_path").val(),
					    oldPath : $("#file_path").val(),
					    permission : $("#permission").val()
					},
					elem: '#upload-file-btn', //指定原始元素，默认直接查找class="layui-upload-file"
					accept: "file",
					ext: $("#file_type").val(), //上传文件类型限制
					method: 'POST', //上传接口的http类型
					done: function(res){
					    res.permission = $("#permission").val();
					    fileData = res;
					    if (res.result == "SUCCESS") {
							layer.msg('上传成功');
							console.log(res);
							$("#LAY_upload").show().attr("src", res.pathShow);
						    $("#file_path").val(res.path);
					    }
					    isLoading = false;
				    }
			    });
			}
			
			function callbackdata() {
			    var data = fileData;
			    if (data != null && typeof data != 'undefined') {
				    data.fileId = $("#file_id").val();
			    }
			    return data;
			}
		</script>
	</head>
	<body>
		<div id="div-body" style="">
			<div class="hid-scroller-body">
				<div class="main-container" style="margin: 0;">
					<fieldset class="layui-elem-field layui-field-title">
						<legend>上传文件</legend>
					</fieldset>
					<div class="site-demo-upload upload-file-btn-group">
						<#if (documentBean.pathShow?? && documentBean.pathShow != '')>
							<#assign var_class = 'fn-show'/>
						<#else>
							<#assign var_class = 'fn-hide'/>
						</#if>
						<img id="LAY_upload" src="${documentBean.pathShow!}" class="${var_class}">
						<div class="site-demo-upbar">
							<div class="layui-upload-drag" id="upload-file-btn">
								<i class="layui-icon">&#xe67c;</i>
								<p>点击上传，或将文件拖拽到此处</p>
							</div>
						</div>
					</div>
					<#if documentBean.fileId?? && documentBean.fileId != ''>
						<#assign show_class = 'fn-show'/>
					<#else>
						<#assign show_class = 'fn-hide'/>
					</#if>
					<div class="layui-form-item ${show_class}" style="margin-top: 42px;">
						<label class="layui-form-label">调用路径</label>
						<div class="layui-input-inline">
							<input type="text" readonly="readonly" class="layui-input" value="${documentBean.pathShow!}" style="width: 290px;">
						</div>
					</div>
					<input id="folder_path" type="hidden" value="${parentBean.path!}">
					<input id="permission" type="hidden" value="${parentBean.permission!}">
					<input id="file_path" type="hidden" value="">
					<input id="file_id" type="hidden" value="${documentBean.fileId!}">
					<input id="file_type" type="hidden" value="${documentBean.fileType!}">
				</div>
			</div>
		</div>
	</body>
</html>